<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .nav{
            width: 100px;
            height: 30px;
            background-color: antiquewhite;
        }
        .li{
            float: left;
            width: 100px;
            height: 30px;
            background-color: pink;
            list-style: none;
        }
        .a{
            text-decoration: none;
        }
    </style>
</head>
<body>
    <div>
        <ul class="nav">
            <li>
                <a href="#">家用家电</a>
                <ul>
                    <li>
                        <a href="#">冰箱</a>
                    </li>
                    <li>
                        <a href="#">冰箱</a>
                    </li>
                    <li>
                        <a href="#">冰箱</a>
                    </li>
                </ul>
            </li>
            
        </ul>
    </div>
</body>
<script>
    //获取元素
    let nav = document.querySelector('.nav');
    let lia=nav.children;
    //注册鼠标经过事件和鼠标离开事件
    for(let i=0;i<lia.length;i++){
        lia[i].onmouseover=function(){
            lia[i].onmouseover=function(){
                this.children[1].style.display='block';
            };
            lia[i].onmouseout=function(){
                this.children[1].style.display='none';
            };
        }
    }
</script>
</html>